
    var shopid = 0
    var areaid = 0
    function getPull2(){
        document.getElementById('pull1').style.display = 'none'
        if(document.getElementById('pull2').style.display === 'none'){
            document.getElementById('pull2').style.display = 'block'
        }else{
            document.getElementById('pull2').style.display = 'none'
        }
    }
    function getPull1(){
        document.getElementById('pull2').style.display = 'none'
        if(document.getElementById('pull1').style.display === 'none'){
            document.getElementById('pull1').style.display = 'block'
        }else{
            document.getElementById('pull1').style.display = 'none'
        }
    }

    function initDate(){
       ajax({
           url:'http://chst.vip:1234/api/getgsshop',
           method:'get',
           data: {
             //  xxx:xxx
           },//需要传递的参数
           async: true,//默认是异步的
           headers: { //请求头
               "Content-Type": "application/x-www-form-urlencoded"
           },
       }).then(res => {
           var data = res.result
           console.log(data,"data");
           data.forEach((obj,index) => {
            var li = document.createElement('li')
            li.innerHTML = data[index].shopName
            li.id = data[index].shopId
            li.addEventListener('click', function (ev) {
                document.getElementById('pull1').style.display = 'none'
                var target = ev.target || ev.srcElement;
                console.log(target.id,"evevevev");
                shopid = target.id
                //好了 在这里吗调商品列表接口就就行了 
                getShop()
            })
            document.querySelectorAll('#pull1 > ul')[0].appendChild(li)
           });
           data.forEach((obj,index) => {
               var img = document.createElement('img')
               img.src = data[index].couponImg
               document.querySelectorAll('#cenUl > li')[index].appendChild(img)
           });
       })
   }
   //点击对应下拉 获取对应商品列表
  function getData(id){
    console.log(id,"获取到了");
    
   }
   initDate()
   
//地区
   function iDate(){
       ajax({
           url:'http://chst.vip:1234/api/getgsshoparea',
           method:'get',
           data: {},//需要传递的参数
           async: true,//默认是异步的
           headers: { //请求头
               "Content-Type": "application/x-www-form-urlencoded"
           },
       }).then(res => {
           var data = res.result
           console.log(data);
           data.forEach((obj,index) => {
            var li = document.createElement('li')
            li.innerHTML = data[index].areaName
            li.id = data[index].areaId
            li.addEventListener('click', function (ev) {
                document.getElementById('pull2').style.display = 'none'
                var target = ev.target || ev.srcElement;
                console.log(target.id,"ev");
                areaid = target.id
                //好了 在这里吗调商品列表接口就就行了 
                getShop()
            })
            document.querySelectorAll('#pull2 > ul')[0].appendChild(li)
           });
           data.forEach((obj,index) => {
               var img = document.createElement('img')
               img.src = data[index].couponImg
               document.querySelectorAll('#cenUl > li')[index].appendChild(img)
           });
           
           
       })
   }

   iDate()
    //获取商品列表
    function getShop(){
        let arr = document.querySelectorAll('#liKey')
        arr.forEach(obj=>{
            obj.remove()
        })
        ajax({
           url:'http://chst.vip:1234/api/getgsproduct',
           method:'get',
           data: {
            shopid :shopid,
            areaid :areaid,
           },//需要传递的参数
           async: true,//默认是异步的
           headers: { //请求头
               "Content-Type": "application/x-www-form-urlencoded"
           },
       }).then(res=>{
        var formDate =  res.result
        formDate.forEach((item,index)=>{
        let li = document.createElement('li')
        li.id = 'liKey'
            li.innerHTML = `
                    <a href="">
                        <img src="${item.productImg}" alt="">
                        <div class="title">${item.productName}</div>
                        <p class="price">${item.productPrice}</p>
                    </a>
                `
        document.querySelectorAll('#content > ul')[0].appendChild(li)
        })
       })
    }
    //列表
    getShop()